Trace: • bindings
Tutorial: bindings
In this tutorial you will explore a common use case where the mesh bindings system comes in handy. In order to follow this tutorial you will have to import the Total Baker Samples package.
1. Create a new scene
2. Go to Assets/TotalBakerSamples/Balcony and find the models Balcony_Low and Balcony_High, then drag them in scene.
3. Depending on your current Render Pipeline (URP or Standard), you may have to assign the proper materials that can be found in the same folder.
4. Open the Total Baker window: Tools/Total Baker/Open Total Baker
5. Use as lowpoly and highpoly inputs, respectively, the models “Balcony_Low” and “Balcony_High”.
6. Click on the Validate button
10. Click on Generate. Looking at the cage (wireframe blue model), you can note that some faces are disconected. This happens because the auto cage generation works by vertex expansion (each vetex of the lowpoly model is expanded along its normal). Having set the lowpoly's normals smoothing angle to 60 means that all its adjacent triangles whose normals differ from each other by more than 60° will be split. This isn't some custom algorithm, it's just how Unity works when dealing with normals smoothing calculation. This is a very fortunate case, because this model is composed by right angles only, and all the coplanar faces will be expanded together.
11. Focus on the cage model. It has two meshes: the railings and the wall+door. Both meshes share the same material. This is fine, since all Total Baker only supports a single material on lowpoly models.
12. Now click on the to hide the cage and inspect the highpoly model. You can see that it is composed by 6 meshes, each with a single material.
13. In the Settings Panel set the max ray length to 1: this will ensure the rays will always be longer than the cage offset.
14. In the Maps Panel, select only the Diffuse map.
15. Start the bake by clicking on the button.
16. When the bake process finishes, select the Diffuse map below the texture preview area. You should see something like this
As you can see, in the spaces between the railings (identified by the arrows) the green door's colors have been baked instead of transparency. That's because the rays passed through the empty space and intersected the green door.
17. In order to make the rays not intersect the door when passing through the spaces between the railings, we can use the Mesh Bindings system. The idea is to bind to the cage's railings mesh the only highpoly's railings mesh. In this way, each ray cast from the cage railings will only collide with the bound mesh (the highpoly railings). To do so, go in the 3D Models panel and enable the Bindings checkbox in the cage section.
18. Select the “Railings” cage mesh and then bind to it the “Balcony” highpoly mesh. Unbind all the other meshes.
19. Now select the “Wall” cage mesh and bind to it all the highpoly meshes except “Balcony”.
20. Bake again by clicking on the button. Now the railings are correct!
21. Check the lowpoly model in the preview scene. The railings are ok, but the space between them is black.
22. Change the Blend Mode value for the lowpoly model from Opaque to Cutout. This should fix the transparency:
Congratulations, tutorial completed! You have learned how to use the mesh binding system to prevent some highpoly meshes from being hit by rays coming from a cage mesh in order to fix incorrectly opaque areas. The next part is just a fine-tuning exercise, which will lead you to a better bake for this model.
23. Set the resolution to 2048 in the Settings Panel
24. Select the Metallic Map in the Maps Panel
21. Select the AO Map in th Maps Panel and use the following values:
- AO Algorithm: Classic
- Occlusion Strength: 1
- Max Spread: 0.05
- Rays Per Point: 50
- Bake into diffuse: true
25. Bake again
26. In the Diffuse filters, use the following values:
- Dilation mode: Alpha Mask
- Dilation: 10
27. In the AO filters, use the following values:
- Dilation mode: Opaque
- Dilation: 10
- Blur: 10
- Brightness: -0.35
- Contrast: 2.7
28. The final result should be like this: